<template>
    <div>
        <van-sticky>
            <van-nav-bar title="分类" />
        </van-sticky>
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="item in fl" :title="item.cat_name" />
                </van-sidebar>
            </van-col>
            <van-col span="18">
                <div v-for="item in fl[active]?.children">
                    <h4>{{ item.cat_name }}</h4>
                    <van-grid :column-num="3">
                        <van-grid-item v-for="value in item.children" @click="tz(value.cat_id)" :icon="value.cat_icon" :text="value.cat_name" />
                    </van-grid>

                </div>
            </van-col>
        </van-row>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router';
import { claaApi } from '../../request/api';

const router = useRouter()
const active = ref(0);
const fl = ref([])
claaApi().then(res => {
    fl.value = res.data.message
})

const tz=(cid)=>{
    router.push({
        path:'/goods',
        query:{cid}
    })
}

</script>

<style lang="scss" scoped></style>